﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 实验四._1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            this.Invalidate();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            //图形工具类
            Graphics g = e.Graphics;
            //绘制鼠标坐标信息--文字
            String sb = "文字绘制演示";
            Font font = new Font("微软雅黑", 20f);//测试Font类
            SolidBrush Sbrush = new SolidBrush(Color.Crimson);//测试Brush类
            //绘制文字
            e.Graphics.DrawString(sb, font, Sbrush, 350f, 280f);
            //绘制分割线
            Pen pen = new Pen(Color.Black, 2.0f);//测试Pen类
            g.DrawLine(pen, this.ClientRectangle.Width / 2,
                0,
                this.ClientRectangle.Width / 2,
                this.ClientRectangle.Height
                );
            g.DrawLine(pen, 0, this.ClientRectangle.Height / 2,
                this.ClientRectangle.Width,
                this.ClientRectangle.Height / 2
                );
            //绘制图形
            pen.Color = Color.Blue;
            g.DrawRectangle(pen, 2, 2, 300, 300);
            g.FillRectangle(new SolidBrush(Color.LightBlue), 15, 15, 274, 214);
            pen.Color = Color.DeepPink;
            //绘制图片  测试Image类
            Bitmap bm = new Bitmap(Application.StartupPath + "\\c.png");
            g.DrawImage(bm, new Rectangle(2, 290, 360, 240));
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
